<template>
  <div class="div-main">
    <div class="div-login">
      <el-form class="form-login" ref="userVo" :model="userVo">

        <el-input v-model="userVo.username" class="input-username" placeholder="用户名"></el-input>

        <el-input v-model="userVo.mobile" placeholder="请输入手机号码" style="margin-bottom: 10px">
        </el-input>

        <el-input v-model="userVo.password" class="input-pswd" type="password" placeholder="用户密码">
        </el-input>

        <el-input v-model="againPwd" class="input-pswd" type="password" placeholder="确认密码">
        </el-input>

        <el-button round class="btn-login" @click="register">注册</el-button>

      </el-form>

    </div>
  </div>
</template>

<script>

import memberRegister from '@/api/member/member'

export default {
  name: "login",
  data() {
    return {
      userVo: {},
      againPwd: '',  //确认密码
    }
  },

  methods : {
    openWeiboLogin() {
      location.href = "https://api.weibo.com/oauth2/authorize?client_id=477905441&response_type=code&redirect_uri=http://gmmallauth.com/weibo/login"
    },

    //注册
    register() {
      //校验密码
      if (this.userVo.password != this.againPwd) {
        this.$message({
          message: '密码输入不一致',
          type: 'error'
        })
        return
      }

      memberRegister.memberRegister(this.userVo)
      .then(res => {
        this.$router.push('/login')
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style scoped>
.div-main {
  width: 100%;
  height: 100%;
}

.div-login {
  background-color: rgba(61, 61, 61, 0.5);
  border-radius: 10px;
  float: right;
  height: 25rem;
  width: 23rem;
  /*padding-right: 10rem;*/
  margin-right: 10rem;
  margin-top: 5rem;
  margin-bottom: 4rem;
}

.form-login {
  margin-top: 2rem;
  margin-right: 5px;
  margin-left: 5px;
}

.input-username {
  background-color: #99a9bf;
  margin-bottom: 10px;
  border-radius: 5px;
}

.input-pswd {
  margin-bottom: 10px;
}

.btn-login {
  margin-top: 10px;
  width: 100%;
}

.tipareas {
  margin-top: 10px;
  text-align: right;
  font-size: 15px;
  color: #ffffff;
}

.third-party {
  margin-top: 6rem;
  text-align: center;
}
</style>